<template>
  <section v-loading="loading" class="cms-body">
    <div class="cms-list-header flex-between">
      <div>
        <el-select v-model="params.state" @change="goQuery()">
          <el-option label="状态" value=""></el-option>
          <el-option label="未处理" value="0"></el-option>
          <el-option label="已处理" value="1"></el-option>
        </el-select>
        <cms-input label="姓名" v-model="params.nickName"></cms-input>
        <cms-input label="手机号码" v-model="params.mobile"></cms-input>
        <el-date-picker
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            v-model="params.queryTime"
            type="daterange"
            align="left"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        <el-button @click="goQuery()">查询</el-button>
      </div>
    </div>

    <!-- 表格 -->
    <el-table :data="tableData" stripe style="width: 100%" @selection-change="checkIds">
      <el-table-column type="selection" width="65" align="right"></el-table-column>
      <el-table-column prop="id" label="id" width="180" align="center"></el-table-column>
      <el-table-column prop="nickName" label="用户姓名"  align="center"></el-table-column>
      <el-table-column prop="mobile" label="手机号码" align="center"></el-table-column>
      <el-table-column prop="state" label="处理状态"  align="center">
        <div slot-scope="scope">
          <span v-if="scope.row.state==0">未处理</span>
          <span v-if="scope.row.state==1">已处理</span>
        </div>
      </el-table-column>
      <el-table-column prop="content" label="反馈内容"  align="center"></el-table-column>
      <el-table-column prop="remark" label="备注"  align="center"></el-table-column>
      <el-table-column prop="createTime" label="反馈日期"  align="center"></el-table-column>

      <el-table-column label="操作" align="center">
        <div slot-scope="scope">
          <cms-button type="edit" @click.native="routerLink('/feedback/update','update',scope.row.id)" v-perms="'/feedback/update'"></cms-button>
          <cms-button type="delete" @click.native="deleteBatch($api.feedbackDelete,scope.row.id)" v-perms="'/feedback/delete'"></cms-button>
        </div>
      </el-table-column>
    </el-table>

    <!-- 表格底部 -->
    <div class="cms-list-footer">
      <div class="cms-left"></div>
      <cms-pagination :total="total" @change="getPages"></cms-pagination>
    </div>

  </section>
</template>

<script>
  import listMixins from '@/mixins/list'

  export default {
    mixins: [listMixins],
    data() {
      return {
        params: {//只需要业务参数
          pageNo: 1,
          pageSize: 10,
          state:'',
          nickName: '',
          mobile: '',
          queryTime: '',
          startTime: '',
          endTime: ''
        }
      };
    },
    methods: {
      goQuery() {
        let queryTime = this.params.queryTime;
        if (!this.$myUtils.isNull(queryTime)) {
          for (let i in queryTime) {
            let time = queryTime[i];
            if (i == 0) {
              this.params['startTime'] = time;
            }
            if (i == 1) {
              this.params['endTime'] = time;
            }
          }
        }
        console.log(this.params);
        this.getTableData(this.params);
      },
      batchUpdate(url) { //保存排列循序
        let params = [];
        for (let i in this.checkedList) {
          let param = this.checkedList[i];
          param['integralGoodsId'] = param.id;
          params.push(param)
        }
        params = JSON.stringify(params);
        this.$confirm('是否保存?', '提示', {type: "warning"}).then(mes => {
          this.$http.post(url, {params: params}).then(res => {
            if (res.code == "200") {
              this.successMessage('操作成功');
              this.getTableData(this.params);
            }
          });
        }).catch(error => {
          console.log(error)
        });
      }
    },
    created() {
      this.initTableData(this.$api.feedbackPageList, this.params);
    }
  };
</script>

<style>

</style>
